<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>WebSocket Demo</title>
    <script>
        var ws = new WebSocket('ws://localhost:5800/echo');
        ws.onopen = function() {
            console.log('WebSocket 连接已经建立。');
            ws.send('Hello, server!');
        };
        ws.onmessage = function(event) {
            console.log('收到服务器消息：', event.data);
        };
        ws.onerror = function(event) {
            console.error('WebSocket 连接出现错误：', event);
        };
        ws.onclose = function() {
            console.log('WebSocket 连接已经关闭。');
        };
    </script>
</head>
<body>
<h1>WebSocket Demo</h1>
</body>
</html>